package com.dogdog.UI;

import com.dogdog.activity.R;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;

public class DialogOpenFace extends Dialog {
	/**
	 * 本类专门用于打开头像设置的
	 * */
	
	//定义回调事件，用于dialog的点击事件
    public interface OnCustomDialogListener {
            public void back(int requestCode);
    }
    
    private OnCustomDialogListener customDialogListener;

    public DialogOpenFace(Context context,OnCustomDialogListener customDialogListener) {
            super(context);
            this.customDialogListener = customDialogListener;
    }
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    	super.requestWindowFeature(Window.FEATURE_NO_TITLE);
    	super.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_background);
    ((Button) findViewById(R.id.camera)).setOnClickListener(clickListener);
    ((Button) findViewById(R.id.gallery)).setOnClickListener(clickListener);
}

private View.OnClickListener clickListener = new View.OnClickListener() {
        
        @Override
        public void onClick(View v) {
        	int requestCode=0;
        	switch (v.getId()) {
			case R.id.camera:
				requestCode=0;//打开相机的返回码
				break;
  
			case R.id.gallery:
			    requestCode=1;//本地图库返回码
				break;
				
			default:
				requestCode=1;
				break;
			}
                customDialogListener.back(requestCode);
            DialogOpenFace.this.dismiss();
        }
};
}
